import { PlatformInterface } from '#/PlatformInterface'
import { c } from 'vite/dist/node/types.d-aGj9QkWt'
export const getPlatformInfo = () => {
  const platformData: PlatformInterface = {
    platform: '',
    env: import.meta.env.MODE,
    baseUrl: '',
  }
  //微信
  // #ifdef MP-WEIXIN
  platformData.baseUrl = import.meta.env.VITE_BASE_BASE_API_WEIXIN
  platformData.platform = 'WEIXIN'
  console.log('微信小程序环境', platformData.baseUrl)
  // #endif

  //H5
  // #ifdef H5
  platformData.baseUrl = import.meta.env.VITE_BASE_BASE_API_H5
  platformData.platform = 'H5'
  console.log('H5环境', platformData.baseUrl)
  // #endif

  //WEB
  // #ifdef WEB
  platformData.baseUrl = import.meta.env.VITE_BASE_BASE_API_WEB
  platformData.platform = 'WEB'
  console.log('WEB环境', platformData.baseUrl)
  // #endif

  //鸿蒙元服务
  // #ifdef MP-HARMONY
  platformData.baseUrl = import.meta.env.VITE_BASE_BASE_API_HARMONY
  platformData.platform = 'HARMONY'
  console.log('鸿蒙元服务环境', platformData.baseUrl)
  // #endif

  //支付宝小程序
  // #ifdef MP-ALIPAY
  platformData.baseUrl = import.meta.env.VITE_BASE_BASE_API_ALIPAY
  platformData.platform = 'ALIPAY'
  console.log('支付宝小程序环境', platformData.baseUrl)
  // #endif

  //抖音小程序
  // #ifdef MP-TOUTIAO
  platformData.baseUrl = import.meta.env.VITE_BASE_BASE_API_TOUTIAO
  platformData.platform = 'TOUTIAO'
  console.log('抖音小程序环境', platformData.baseUrl)
  // #endif

  //飞书小程序
  // #ifdef MP-LARK
  platformData.baseUrl = import.meta.env.VITE_BASE_BASE_API_LARK
  platformData.platform = 'LARK'
  console.log('飞书小程序环境', platformData.baseUrl)
  // #endif

  //快手小程序
  // #ifdef MP-KUAISHOU
  platformData.baseUrl = import.meta.env.VITE_BASE_BASE_API_KUAISHOU
  platformData.platform = 'KUAISHOU'
  console.log('快手小程序环境', platformData.baseUrl)
  // #endif

  //京东小程序
  // #ifdef MP-JD
  platformData.baseUrl = import.meta.env.VITE_BASE_BASE_API_JD
  platformData.platform = 'JD'
  console.log('京东小程序环境', platformData.baseUrl)
  // #endif

  //小红书小程序
  // #ifdef MP-XHS
  platformData.baseUrl = import.meta.env.VITE_BASE_BASE_API_XHS
  platformData.platform = 'XHS'
  console.log('小红书小程序环境', platformData.baseUrl)
  // #endif

  //鸿蒙APP
  // #ifdef APP-HARMONY
  platformData.baseUrl = import.meta.env.VITE_BASE_BASE_API_HARMONYAPP
  platformData.platform = 'HARMONYAPP'
  console.log('鸿蒙APP环境', platformData.baseUrl)
  // #endif

  let port = uni.getSystemInfoSync().platform
  //安卓
  if ((port === 'ANDROIDAPP' || port === 'android') && !platformData.baseUrl) {
    platformData.baseUrl = import.meta.env.VITE_BASE_BASE_API_ANDROID
    platformData.platform = 'ANDROIDAPP'
  }
  //IOS
  if ((port === 'IOS' || port === 'ios') && !platformData.baseUrl) {
    platformData.baseUrl = import.meta.env.VITE_BASE_BASE_API_IOS
    platformData.platform = 'IOSAPP'
  }
  return platformData
}

export const getSystemInfo = () => {
  const systemInfo = uni.getSystemInfoSync() // 获取手机 系统信息
  return systemInfo.statusBarHeight as any
}
